/**
 * Created by Administrator on 2017/7/16.
 */
(function ($) {
    $.extend($.expr[':'], {
        group: function (element, index, matches, set) {
            var num = parseInt(matches[3], 10);
            if (isNaN(num)) {
                return false;
            }
            return index % (num * 2) < num;
        }
    });
})(jQuery);

$(document).ready(function () {
    var $news = $('#news');

    function stripe() {
        $news.find('tr.alt').removeClass('alt');
        $news.find('tbody').each(function () {
            $(this).children(':visible').has('td')
                .filter(':group(3)').addClass('alt');
        });
    }

    stripe();

    $('#topics a').click(function (e) {
        e.preventDefault();
        var topic = $(this).text();
        $('#topics a.selected').removeClass('selected');
        $(this).addClass('selected');
        $('#news').find('tr').show();
        if (topic !== 'All') {
            $('#news').find('tr:has(td)').not(function () {
                return $(this).children(':nth-child(4)').text() === topic;
            }).hide();
        }
        stripe();
    });
});

$(document).ready(function () {
    var $cell = $('#release').nextAll();
    $cell.addClass('highlight');
    console.log($cell.context);
    console.log($cell.selector);
    console.log($cell.proveObject);
});

$.fn.column = function () {
    var $cells = $();
    this.each(function () {
        var $td = $(this).closest('td, th');
        if ($td.length) {
            var colNumber = $td[0].cellIndex + 1;
            var $columnCells = $td
                .closest('table')
                .find('td, th')
                .filter(':nth-child(' + colNumber + ')');
            $cells = $cells.add($columnCells);
        }
    });
    return this.pushStack($cells);
};

$(document).ready(function () {
    $('#news td').click(function () {
        $('#news td.active').removeClass('active');
        $(this).column().addClass('active');
    });
});